﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PoliAsis.Domain.Entities
{
    public class PoliUser : BaseObject
    {
        public string name { get; set; }
        public string surname { get; set; }
        public string person_code { get; set; }
        public string password { get; set; }
        public string matricola { get; set; }
        public string email { get; set; }
        public string auth_token { get; set; }
        public DateTime? auth_token_date { get; set; }
        public int? user_major { get; set; }
        public int? start_academic_year { get; set; }
        public int? finish_academic_year { get; set; }
        

        public bool IsTokenValid()
        {
            if (String.IsNullOrEmpty(auth_token)) return false;
            if (auth_token_date == null) return false;

            TimeSpan tspan = DateTime.Now - auth_token_date.Value;
            if (tspan.TotalDays > 1)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
